package com.zhuannimei.parser;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.zhuannimei.domain.HistoryOneShop;

public class HistoryOneShopParser extends BaseJSONParser<List<HistoryOneShop>> {

	@Override
	public List<HistoryOneShop> parseJSON(String jsonstr) throws JSONException {
		List<HistoryOneShop> list = new ArrayList<HistoryOneShop>();
		JSONObject jo = new JSONObject(jsonstr);
		JSONArray jsonArray = jo.getJSONArray("result");
		for (int i = 0; i < jsonArray.length(); i++) {
			JSONObject obj = jsonArray.getJSONObject(i);
			HistoryOneShop osp = new HistoryOneShop();
			osp.setId(UUID.randomUUID()+"");
			osp.setLuckId(obj.optString("luckId"));
			osp.setCtime(obj.optString("ctime"));
			osp.setPhase(obj.optString("phase"));
			osp.setPicture(obj.optString("picture"));
			osp.setPrice(obj.optString("price"));
			osp.setTitle(obj.optString("title"));
			osp.setStatus(obj.optString("status"));
			osp.setDescribe(obj.optString("describe"));
			osp.setPoint(obj.optString("point"));
			osp.setNumber(obj.optString("number"));
			list.add(osp);
		}
		return list;
	}

}
